package com.ylsk.check.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ylsk.check.domain.vo.ExpresswaySectionVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ylsk.common.annotation.Log;
import com.ylsk.common.core.controller.BaseController;
import com.ylsk.common.core.domain.AjaxResult;
import com.ylsk.common.enums.BusinessType;
import com.ylsk.check.domain.ExpresswaySection;
import com.ylsk.check.service.IExpresswaySectionService;
import com.ylsk.common.utils.poi.ExcelUtil;
import com.ylsk.common.core.page.TableDataInfo;

/**
 * 高速路段管理Controller
 *
 * @author yangsy
 * @date 2023-12-06
 */
@RestController
@RequestMapping("/check/expresswaySection")
public class ExpresswaySectionController extends BaseController
{
    @Autowired
    private IExpresswaySectionService expresswaySectionService;

    /**
     * 查询高速路段管理列表
     */
    @PreAuthorize("@ss.hasPermi('check:expresswaySection:list')")
    @GetMapping("/list")
    public TableDataInfo list(ExpresswaySection expresswaySection)
    {
        startPage();
        List<ExpresswaySectionVO> list = expresswaySectionService.selectExpresswaySectionList(expresswaySection);
        return getDataTable(list);
    }

    /**
     * 导出高速路段管理列表
     */
    @PreAuthorize("@ss.hasPermi('check:expresswaySection:export')")
    @Log(title = "高速路段管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ExpresswaySection expresswaySection)
    {
        List<ExpresswaySectionVO> list = expresswaySectionService.selectExpresswaySectionList(expresswaySection);
        ExcelUtil<ExpresswaySectionVO> util = new ExcelUtil<ExpresswaySectionVO>(ExpresswaySectionVO.class);
        util.exportExcel(response, list, "高速路段管理数据");
    }

    /**
     * 获取高速路段管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('check:expresswaySection:query')")
    @GetMapping(value = "/{expresswaySectionId}")
    public AjaxResult getInfo(@PathVariable("expresswaySectionId") Long expresswaySectionId)
    {
        return success(expresswaySectionService.selectExpresswaySectionByExpresswaySectionId(expresswaySectionId));
    }

    /**
     * 新增高速路段管理
     */
    @PreAuthorize("@ss.hasPermi('check:expresswaySection:add')")
    @Log(title = "高速路段管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ExpresswaySection expresswaySection)
    {
        return toAjax(expresswaySectionService.insertExpresswaySection(expresswaySection));
    }

    /**
     * 修改高速路段管理
     */
    @PreAuthorize("@ss.hasPermi('check:expresswaySection:edit')")
    @Log(title = "高速路段管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ExpresswaySection expresswaySection)
    {
        return toAjax(expresswaySectionService.updateExpresswaySection(expresswaySection));
    }

    /**
     * 删除高速路段管理
     */
    @PreAuthorize("@ss.hasPermi('check:expresswaySection:remove')")
    @Log(title = "高速路段管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{expresswaySectionIds}")
    public AjaxResult remove(@PathVariable Long[] expresswaySectionIds)
    {
        return toAjax(expresswaySectionService.deleteExpresswaySectionByExpresswaySectionIds(expresswaySectionIds));
    }

    /**
     * 查询高速路段管理不分页列表
     */
    @GetMapping("/selectList")
    public AjaxResult selectList(ExpresswaySection expresswaySection)
    {
        List<ExpresswaySectionVO> list = expresswaySectionService.selectExpresswaySectionList(expresswaySection);
        return success(list);
    }
}
